<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="utf-8"%>
<%@ include file="../include/head.jsp"%>
<%@ include file="../include/top.jsp"%>
<%@ include file="../include/left.jsp"%>

<div class="main-content">

	<%@ include file="../include/navigate.jsp" %>

	<div class="container">

		<c:if test="${error != null }">
			<div class="alert alert-danger alert-dismissable">
				<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
				<strong>异常:</strong> ${error}
			</div>
		</c:if>
		<c:if test="${msg != null }">
			<div class="alert alert-info alert-dismissable">
				<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
				<strong>提示:</strong> ${msg}
			</div>
		</c:if>
		<div class="row clearfix ">
			<div class="col-sm-12">
				<div class="widget-box">
					<div class="widget-box-header">
						<div class="col-sm-9">
							<div class="title">角色列表</div>
						</div>
						<div class="col-sm-3"  style="text-align:right;">
							<c:if test="${sessionScope.validUrls.contains('/role/add')}">
								<div class="btn-group-sm" style="padding: 2px;">
									<a type="button" class="btn btn-default btn-sm glyphicon glyphicon-plus" href="/role/add"> 添加 </a>
								</div>
							</c:if>
						</div>
					</div>
					<div class="widget-box-content" style="padding: 15px;">
						<div class="dataTables_wrapper form-inline">
							<div class="table-responsive">
								<div class="table-responsive">
									<table class="table table-hover">
										<thead>
											<tr>
												<th>角色名称</th>
												<th>创建时间</th>
												<th>角色功能描述</th>
												<th>操作</th>
											</tr>
										</thead>
										<tbody>
											<c:forEach items="${roles}" var="role">
												<tr>
													<td>${role.roleName}</td>
													<td><fmt:formatDate value="${role.createDate}" pattern="yyyy-MM-dd HH:mm:ss" /></td>
													<td>${role.des}</td>
													<td>
														<div class="btn-group">
															<c:if test="${role.roleId == '1'}">
																<c:set var="btnStat" value="disabled"></c:set>
															</c:if>
															<c:if test="${role.roleId != '1'}">
																<c:set var="btnStat" value=""></c:set>
															</c:if>
															<c:if test="${sessionScope.validUrls.contains('/role/edit')}">
																<a type="button" class="btn btn-primary" <c:out value="${btnStat}" /> href="${pageContext.request.contextPath}/role/edit?roleId=${role.roleId}">修改 </a>
															</c:if>
															<c:if test="${sessionScope.validUrls.contains('/role/delete')}">
																<button type="button" class="btn btn-danger" <c:out value="${btnStat}" /> onclick="openModal('${pageContext.request.contextPath}/role/delete?id=${role.roleId}&page=${page}','删除角色？','确定要删除当前选中角色吗？')">删除</button>
															</c:if>
															<c:if test="${!sessionScope.validUrls.contains('/role/delete') && !sessionScope.validUrls.contains('/role/edit')}">
																无
															</c:if>
														</div>
													</td>
												</tr>
											</c:forEach>
										</tbody>
									</table>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<div class="row clearfix ">
			<div class="col-md-4"></div>
			<div class="col-md-4">
				<nav>
					<ul class="pagination pagination-sm"></ul>
				</nav>
			</div>
		</div>
		<div style="position: fixed; bottom: 0px; width: 100%;" align="center">
			<%@ include file="../include/footer.jsp"%>
		</div>
	</div>
	
	<script type="text/javascript">
	    $('.pagination').twbsPagination({
	        totalPages: ${pageInfo.pages},
	        visiblePages: 5,
	        href: '?page={{number}}'
	    });
	</script>

	<%@ include file="../include/bottom.jsp"%>